#include<iostream>
#include<algorithm>

using namespace std;

const int N = 3e4 + 10;
int a[N] ;

int main()
{
	int w, n; cin >> w >> n;
	int sum = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	sort(a + 1, a + n+1);
	int num = 0; int right = n, left = 1;
	while(left<=right)
	{
		sum = a[left] + a[right];
		if (sum <= w)
		{
			num++;
			left++; right--;
		}
		else if (sum > w)
		{
			num++;
			right--;
		}
	}
	
	cout << num;
	return 0;
}
